/*
 * Copyright (C) 2012-2013  Romain DUBOIS
 * 
 * This file is part of NeMoS - Network and Modular Software
 * 
 * NeMoS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * NeMoS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with NeMoS.  If not, see <http://www.gnu.org/licenses/>.
 */
package nemos.remote.discovery.internal;

import nemos.remote.discovery.IEndpointDispatcher;
import nemos.remote.util.EplEndpointProvider;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.Constants;
import org.osgi.service.remoteserviceadmin.EndpointDescription;

/**
 * EndpointDispatcherImpl : The {@link IEndpointDispatcher} implementation.
 * 
 * @see IEndpointDispatcher
 * 
 * @author Romain DUBOIS
 */
@Service(IEndpointDispatcher.class)
@Property(name = Constants.SERVICE_EXPORTED_INTERFACES, value = "nemos.remote.discovery.IEndpointDispatcher")
@Component
public class EndpointDispatcherImpl extends EplEndpointProvider implements IEndpointDispatcher {

    /**
     * Constructor
     */
    public EndpointDispatcherImpl() {
        super();
    }

    /**
     * {@inheritDoc}
     * 
     * @see nemos.remote.discovery.IEndpointDispatcher#dispatch(org.osgi.service.remoteserviceadmin.EndpointDescription)
     */
    @Override
    public void dispatch(final EndpointDescription pEndpoint) {
        notifyListeners(pEndpoint, true);
    }

    /**
     * {@inheritDoc}
     * 
     * @see nemos.remote.discovery.IEndpointDispatcher#cancel(org.osgi.service.remoteserviceadmin.EndpointDescription)
     */
    @Override
    public void cancel(final EndpointDescription pEndpoint) {
        notifyListeners(pEndpoint, false);
    }
}
